package com.uenpay.im.ui.old.activity.pwd;

import com.qiyunxin.android.http.net.HttpInvokeItem;
import com.qiyunxin.android.http.utils.Utils;
import com.qyx.android.utilities.DateUtils;
import com.uenpay.im.IMApplication;
import com.uenpay.im.configuration.APIConfiguration;

import org.json.JSONObject;

/**
 * @Author: SL
 * @Date: 2016/9/19 11:18
 * @CopyRight: http://www.qiyunxin.com
 * @Parameter: TODO
 * @Function: TODO
 */
public class ResetPayPwdInvokItem extends HttpInvokeItem {
    public class ResetPayPwdInvokItemResult {
        public int status;
        public String msg;
    }
    public ResetPayPwdInvokItemResult getOutput() {
        return (ResetPayPwdInvokItemResult) GetResultObject();
    }

    /**
     * 设置支付密码
     *
     * @param paypassword
     */
    public ResetPayPwdInvokItem(String paypassword, String verCode) {
        String time = DateUtils.getCurrentSeconds() + "";
        String sign = Utils.md5(Utils.md5(IMApplication.getUserMobilePhone()
                + "_" + time));
        String url = APIConfiguration.getBaseUrl()
                + "Purse/Purse/resetPayPwd?newpwd=" + paypassword
                + "&vercode=" + verCode + "&time=" + time + "&sign=" + sign
                + "&oldpwd=&" + APIConfiguration.getCustIdAndToken();
        SetUrl(url);
    }

    @Override
    protected Object DeserializeResult(String responseBody) throws Exception {
        ResetPayPwdInvokItemResult result = new ResetPayPwdInvokItemResult();
        JSONObject json = new JSONObject(responseBody);
        result.status = json.optInt("status");
        result.msg = json.optString("msg");
        return result;
    }

}
